home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Description:
- // This script assigns objects to bakeSets.
- //
-
-
- global proc assignBakeSet (string $bakeSet, string $item)
- {
- string $assignString = $item;
-
- // No bake set ?
- if ($bakeSet == "")
- {
- error( "assignBakeSet: No bake set named." );
- }
-
- string $objs[];
-
- if ($item == "")
- {
- // No object was specified in the call to this procedure, so we will
- // assign the bakeSet to whatever is on the current selection list
- // instead.
- //
- $objs = `ls -dag -objectsOnly -geometry -selection`;
- if (size ($objs) == 0)
- {
- error( "Nothing selected." );
- }
-
- $assignString = "the selected shapes";
-
- if( `nodeType $bakeSet` == "vertexBakeSet" )
- {
- string $meshes[] = `ls -typ mesh $objs`;
- if( size($meshes) < size($objs) )
- {
- warning( "Ignoring non-poly objects in selection list." );
- $objs = $meshes;
- }
- }
- }
- else
- {
- //
- // The $item is always an object, never a component (ie face).
- // If the current selection contains faces of the specified item, then
- // we would rather assign the new bakeSet to the specifically selected
- // faces rather than the object as a whole. In particular, this allows
- // users to select faces of a poly object and use the RMB menu to
- // assign them to bakeSets.
- //
-
- string $selection[] = `ls -selection`;
- int $i;
-
- for ($i = 0; $i < size($selection); $i++)
- {
- if (`match ($item + "\\.f\\[.*\\]") $selection[$i]` != "")
- {
- // One part of the currently selection is faces of the
- // specified item. We will add the selected faces to the list
- // of objects to which the bakeSet will be assigned.
- //
- $objs[size($objs)] = $selection[$i];
- $assignString = ("the selected faces of " + $item);
- }
- }
-
- if (size($objs) == 0)
- {
- // Try again with the shape. Face selection will be names
- // after the shape when other shapes are parented below the
- // transform.
- string $shapes[] = `listRelatives -s $item`;
- if (size($shapes) > 0 )
- {
- string $shape = $shapes[0];
- for ($i = 0; $i < size($selection); $i++)
- {
- if (`match ($shape + "\\.f\\[.*\\]") $selection[$i]` != "")
- {
- $objs[size($objs)] = $selection[$i];
- $assignString = ("the selected faces of " + $shape);
- }
- }
- }
- }
-
- if (size($objs) == 0)
- {
- // There were no faces of the specified item in the current
- // selection. Therefore, we will assign the bakeSet to the
- // entire object specified, more precisely, to object itself
- // if the object is a shape, or all the shapes under the
- // object if the object is a transform.
- //
- $objs = `ls -dag -objectsOnly -geometry $item`;
- }
- }
-
- sets -forceElement $bakeSet $objs;
-
- print (
- "// Result: Assigned "
- + $assignString
- + " to "
- + $bakeSet
- + ". //\n");
- }
-
-